# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-biniou
_pkgname=biniou
pkgver=1.2.1
pkgrel=4
pkgdesc="Extensible binary data format, like JSON but faster"
url="https://github.com/ocaml-community/biniou"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-3-Clause"
depends="ocaml-runtime ocaml-easy-format"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune ocaml ocaml-easy-format-dev ocaml-findlib"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-community/biniou/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build @install
}

check() {
	dune runtest
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
f0166666559f3a767fdc6987bad45ec4a772b70b8880b6d769ef644c9bfd46962f089c7b5dfff368413015e765daf4bacffe253bdb3478d9a4d30a15f0d29589  ocaml-biniou-1.2.1.tar.gz
"
